<?php

namespace App\Console\WxtjCommands;

use App\Services\WxtjArticle;
use Illuminate\Console\Command;

class ArticleSummary extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'wxtj-article:summary
            {beginDate? : 获取数据的起始日期.}
            {endDate? : 获取数据的结束日期.}
            {--all : 是否拉取所有数据}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '图文分析数据统计：图文群发每日数据';
    protected $wxtjArticle;
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(WxtjArticle $wxtjArticle)
    {
        parent::__construct();
        $this->wxtjArticle = $wxtjArticle;
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $isAll = $this->option('all');
        if ($isAll){
            $this->wxtjArticle->pullAllSummary();
        }else{
            $beginDate = $this->argument('beginDate');
            $endDate = $this->argument('endDate');
            $this->wxtjArticle->pullSummary($beginDate, $endDate);
        }
    }
}
